package com.example.demo.mapper;

import com.example.demo.entity.VoicePlan;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.data.repository.query.Param;

import java.util.List;

@Mapper
public interface VoicePlanMapper {
    //通过种类来确定购买的是套餐还是时长
    //将他们进行升序排列将其返回
    @Select("select  * from voiceservice " +
            "ORDER BY price ASC")
    List<VoicePlan> selectAllByCategory();

    //通过服务id来查询单个的商品信息
    @Select("select  * from voiceservice " +
            "where id = #{id} ")
    VoicePlan selectAllByPlanId(@Param("id")int id);

    //通过id获取持续时间
    @Select("SELECT duration FROM voiceservice WHERE id = #{id}")
    double getServiceDurationById(int serviceId);
}
